package org.beans.expense.common.panel;

import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.panel.Panel;

/**
 * @author: arunachalam
 * @since: 2/15/13
 */
public abstract class DataTablePanel extends Panel
{
    public DataTablePanel(String id, String item)
    {
        super(id);
        add(createItemLabel(item));
        add(createLinkGroup());
    }

    private Label createItemLabel(String item)
    {
        return new Label("item", item);
    }

    private WebMarkupContainer createLinkGroup()
    {
        WebMarkupContainer linkContainer = new WebMarkupContainer("linkContainer");
        linkContainer.add(createEditLink());
        linkContainer.add(createDeleteLink());
        return linkContainer;
    }

    private Link createEditLink()
    {
        return new Link("editLink")
        {

            @Override
            public void onClick()
            {
                onEdit();
            }
        };
    }

    private Link createDeleteLink()
    {
        return new Link("deleteLink")
        {
            @Override
            public void onClick()
            {
                onDelete();
            }
        };
    }

    protected abstract void onEdit();

    protected abstract void onDelete();
}

